@{ViewBag.Title = " DestinoAsignado "; Layout = "../Shared/_LayoutJtable.cshtml";}

<div class="filtering"><form>
<label>Filtro por Nombre Personal: <input type="text" name="filter" id="filter" /></label>
<button type="submit" id="LoadRecordsButton" class="button medium orange" >Buscar Coincidencias</button>
 <a class="button medium green" target="_blank" href="~/Reporte/DestinoPersonal">Ver Reporte de la Gestion</a>

</form></div>
<div id="MyTableContainer"></div>
<script type="text/javascript">
     $(document).ready(function () {
     $('#MyTableContainer').jtable({
         title: 'DestinoAsignado',
         paging: true,
         pageSize: 40,
         sorting: true,
         defaultSorting: 'Id ASC',
         actions: {
             listAction: '@Url.Action("JSONPagedListByFilter")',
             deleteAction: '@Url.Action("JSONDelete")',
             updateAction: '@Url.Action("JSONUpdate")'
             
         },
         fields:
         {
          Id: {
                 key: true,
                 create: false,
                 edit: false,
                 list: false
             }
             ,
             Guid: {
                 type: 'hidden'
             }
             ,
             FechaRegistro: {
                 title:'FechaRegistro',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'date',
                 displayFormat: 'dd/mm/yy',
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             FechaAsignacion: {
                 title:'FechaAsignacion',
                 create: true,
                 edit: true,
                 list: true,
                 type: 'date',
                 displayFormat: 'dd/mm/yy',
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             RegistradoPor: {
                 title:'RegistradoPor',
                 create: true,
                 edit: true,
                 list: true,
                 inputClass: 'validate[required]',
                 sorting: false
             }
             ,
             Observaciones: {
                 title:'Observaciones',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }
             ,
             GestionId_FK:{
                 title : 'Gestion',
                 create : true,
                 edit : true,
                 list : true,
                 options : '@Url.Action("../Gestion/JSONGetElementsForDropDownList")'
             }
             ,
             @*PersonaId_FK:{
                 title : 'Persona',
                 create : true,
                 edit : true,
                 list : true,
                 options : '@Url.Action("../Persona/JSONGetElementsForDropDownList")'
             }*@

             Observaciones: {
                 title: 'Observaciones',
                 create: true,
                 edit: true,
                 list: true,
                 sorting: false
             }

             ,            
             NombreCompletoPersona: {
                 title: 'Persona',
                 create: false,
                 edit: false,
                 list: true                 
             },

             Foja: {
                 title: 'Foja',
                 width: '10px',
                 sorting: false,
                 edit: false,
                 create: false,
                 listClass: 'child-opener-image-column',
                 display: function (destinoData) {
                     var $img = $('<img class="child-opener-image" with="15" height="15" src="../../Content/images/services.png" title="Foja de Concepto/Evaluacion" />');
                     //Open child table when user clicks the image
                     $img.click(function () {
                         $('#MyTableContainer').jtable('openChildTable',
                                    $img.closest('tr'),
                                    {
                                        title: 'FOJA DE CONCEPTO EVALUATIVO DE : ' + destinoData.record.Persona.NombreCompleto,
                                        actions: {
                                            listAction: '@Url.Action("../EvaluacionDestino/GetPorDestinoGuid")?guid=' + destinoData.record.Guid,
                                            deleteAction: '@Url.Action("../EvaluacionDestino/JSONDelete")',
                                            updateAction: '@Url.Action("../EvaluacionDestino/JSONUpdate")',
                                            createAction: '@Url.Action("../EvaluacionDestino/JSONCreate")'
                                        },
                                        fields: {
                                            DestinoAsignadoId_FK: {
                                                type: 'hidden',
                                                defaultValue: destinoData.record.Id
                                            },
                                            Guid: {
                                                type: 'hidden'
                                            }
                                            ,
                                            
                                            Descripcion: {
                                                title:'Descripcion',
                                                type: 'textarea',
                                                create: true,
                                                edit: true,
                                                list: true,
                                                sorting: false
                                            }
                                             ,
                                            NotaEvaluacion: {
                                                title:'NotaEvaluacion',
                                                create: true,
                                                edit: true,
                                                list: true,
                                                sorting: false
                                            }
                                            ,
                                            Observaciones: {
                                                title:'Observaciones',
                                                create: true,
                                                edit: true,
                                                list: true,
                                                sorting: false
                                            }
                                             ,
                                            FechaEvaluacion: {
                                                title:'FechaEvaluacion',
                                                create: true,
                                                edit: true,
                                                list: true,
                                                type: 'date',
                                                displayFormat: 'mm-dd-yy',
                                                inputClass: 'validate[required]',
                                                sorting: false
                                            }
                                            ,
                                            FechaRegistro: {
                                                title:'FechaRegistro',
                                                create: false,
                                                edit: false,
                                                list: true,
                                                type: 'date',
                                                displayFormat: 'dd/mm/yy',
                                                inputClass: 'validate[required]',
                                                sorting: false
                                            },
                                            Documento:
                                             {
                                                 title: 'Doc',
                                                 width: '50px',
                                                 sorting: false,
                                                 edit: false,
                                                 create: false,
                                                 listClass: 'child-opener-image-column',
                                                 display: function (tempData) {
                                                     var $img = $('<img class="child-opener-image" with="30" height="30" src="../../Content/images/menu/pictures.png" title="Documento Escaneado" />');
                                                     $img.click(function () {
                                                         //window.open('../Media/Cargar?guid=' + tempData.record.Guid);
                                                         location.href = '../Media/Cargar?guid=' + destinoData.record.Guid + '&titulo=EVALUACION de ' + destinoData.record.Persona.NombreCompleto
                                                     });

                                                     return $img;
                                                 }
                                             }

                                        }
                                    }, function (data) { //opened handler
                                        data.childTable.jtable('load');
                                    });
                     });
                     //Return image to show on the person row
                     return $img;
                 }
             }


},
formCreated: function (event, data) {data.form.validationEngine();},
formSubmitting: function (event, data) {return data.form.validationEngine('validate');},
formClosed: function (event, data) { data.form.validationEngine('hide'); data.form.validationEngine('detach'); }
});
$('#LoadRecordsButton').click(function (e) {e.preventDefault();$('#MyTableContainer').jtable('load', {filter: $('#filter').val()});});
$('#LoadRecordsButton').click();
});
</script>

